<template >
  <div class="home-container" >
    <el-container>
      <el-aside width="200px" v-show="showMenu">
        <el-menu
          default-active="1"
          class="el-menu-vertical-demo"
          @open="handleOpen"
          @close="handleClose"
          background-color="#545c64"
          text-color="#fff"
          active-text-color="#ffd04b"
        >
          <el-menu-item index="1">
            <el-icon><icon-menu /></el-icon>
            <template #title>企业管理</template>
          </el-menu-item>
          <el-sub-menu index="2">
            <template #title>
              <el-icon><location /></el-icon>
              <span>系统管理</span>
            </template>
            <el-menu-item index="2-1" @click="topage('/main/user')">用户管理</el-menu-item>
            <el-menu-item index="2-2"  @click="topage('/main/org')">部门管理</el-menu-item>
            <el-menu-item index="2-3"  @click="topage('/main/role')">角色管理</el-menu-item>
            <el-menu-item index="2-4"  @click="topage('/main/menu')">菜单管理</el-menu-item>
          </el-sub-menu>
        
          <el-menu-item index="4">
            <el-icon><setting /></el-icon>
            <template #title>人事管理</template>
          </el-menu-item>
        </el-menu>
      </el-aside>
      <el-container>

        <el-header>
          <el-row>
            <el-col :span="1">
             <el-icon @click="hideOrShow"><Grid /></el-icon>
            </el-col>

            <el-col :span="17">
              
            </el-col>

            <el-col :span="6">
             <el-icon><User /></el-icon> {{username}}
            </el-col>
          </el-row>
        </el-header>
        <el-main>
          <router-view></router-view>
        </el-main>
        <el-footer>Footer</el-footer>
      </el-container>
    </el-container>
  </div>
</template>

<script setup>
import { ref,onMounted } from 'vue';
import { ElContainer, ElAside, ElMenu, ElMenuItem, ElSubMenu, ElIcon, ElHeader, ElMain, ElFooter } from 'element-plus';
import { Menu as IconMenu, Location, Document, Setting } from '@element-plus/icons-vue';
import { useRouter,useRoute } from 'vue-router';
const route = useRoute();
const router = useRouter();
const username =ref('')
const userid =ref('')
const showMenu = ref(true);

onMounted(()=>{
  username.value = route.query.username
  userid.value = route.query.userid
})
const hideOrShow=()=>{ 
  showMenu.value = !showMenu.value

}
const handleOpen = (key, keyPath) => {
  console.log(key, keyPath);
};

const handleClose = (key, keyPath) => {
  console.log(key, keyPath);
};
//菜单页面跳转
const topage=(path)=>{
  router.push({ path: path })
}
</script>

<style scoped>
.home-container {
  height: 100vh;
  width: 100vw;
}

.el-container {
    height: 100vh;
    width: 100vw;
    margin: 0px;
    padding: 0px;
}

.el-aside {
  background-color: #545c64;
  color: #333;
  text-align: center;
  line-height: 200px;
}

.el-main {
  background-color: #e9eef3;
  color: #333;
  text-align: center;
  line-height: 160px;
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}

.el-header,
.el-footer {
  background-color: #b3c0d1;
  color: #333;
  text-align: center;
  line-height: 60px;
}
</style>